﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace _3D.Data
{
    internal class XMLSerialize
    {
        public static void Serialize(Game game, string name)
        {
            XmlSerializer xs = new XmlSerializer(game.GetType());
            StreamWriter sw = new StreamWriter(@"mazesave_" + name + ".xml", false, Encoding.UTF8);

            xs.Serialize(sw, game);
        }

        public static void Deserialize(ref Game game, string name)
        {

            XmlSerializer xs = new XmlSerializer(typeof(Game));
            StreamReader sr = new StreamReader(@"mazesave_" + name + ".xml", Encoding.UTF8);

            game = (Game)xs.Deserialize(sr);
        }
    }
}